//区域
function TradeArea() {
	$("#tradeArea").html("");
	$.ajax({
		url: urlcore + "/api/tradeArea/selectList",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
				$.each(data.data, function(i, n) {
					var thislist = '<a href="javascript:searchByTradeArea(' + n.id + ');">' + '<span class="tags">' + n.areaName + '</span>' + '</a>';
					$('#tradeArea').append(thislist);
				});
				$(function() {
					//选中
					$('.tagbox a span').on('click', function() {
						$(this).parents('.tagbox').find('a span').removeClass('on');
						$(this).addClass('on');
					});
				})
			}
		},
		error: function() {
			layer.alert("error");
		}
	});

}
//分类
function sortType() {
	$("#sortType").html("");
	$.ajax({
		url: urlcore + "/api/sortType/allSortTypeList",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {

			if(data.success == true) {
				$.each(data.data, function(i, n) {
					var thislist = '<a href="javascript:searchBySortType(' + n.id + ');">' + '<span class="tags">' + n.sortName + '</span>' + '</a>';
					$('#sortType').append(thislist);
				});
				$(function() {
					//选中
					$('.tagbox a span').on('click', function() {
						$(this).parents('.tagbox').find('a span').removeClass('on');
						$(this).addClass('on');
					});
				})
			}
		},
		error: function() {
			layer.alert("error");
		}
	});
}
//属性
function propertyType() {
	$("#property").html("");
	$.ajax({
		url: urlcore + "/api/propertyType/selectTwoList",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {

			if(data.success == true) {
				$.each(data.data.list, function(i, n) {
					var erji = '';
					$.each(n.propertyTypeList, function(i, m) {
						erji += '<a href="javascript:searchByPropertyType(' + m.id + ');">' + '<span data-type="attr" class="search_conditions tags" aid="' + m.oneTypeId + '">' + m.propertyName + '</span>' + '</a>';
					});

					var thislist = '<div class="tattr" id="tattr123">' +
						'<h5 class="tattr-hd">' + n.propertyName + '<i class="icon icon-arrup"></i>' +
						'</h5>' +
						'<p class="tattr-list">' + erji + '</p>' +
						'</div>';
					$('#property').append(thislist);
				});
				//属性js操作
				$('.tattr').on('mouseenter', function() {

					var _this = $(this),
						icon = _this.find('.icon'),
						list = _this.find('.tattr-list');
					icon.addClass('icon-arrdown');

					list.show();
				}).on('mouseleave', function() {
					var _this = $(this),
						icon = _this.find('.icon'),
						list = _this.find('.tattr-list');
					icon.removeClass('icon-arrdown');
					list.hide();
				});
				//属性选择
				$('.tattr-list').on('click', '.tags', function() {
					var _this = $(this),
						html = '<span class="tags">' + _this.text() + ' <span class="close1">X</span></span>',
						parent = _this.parents('.tablist');
					$('#tag').html(html);
					parent.hide();
				});
				// 选择属性删除
				$('#tag').on('click', function() {
					$("#tag .tags").remove();
					parent = $('.tattr-list').parents('.tablist');
					parent.show();
					location.reload();
				});
			}
		},
		error: function() {
			layer.alert("error");
		}
	});
}